package chapter07

object Test04_List {
  def main(args: Array[String]): Unit = {
    //1创建一个List
    val list1 = List(23, 65, 89)
    println(list1)
    // list1(2)=32 这样就会报错
    list1.foreach(println)
    //3.添加元素
    val list2 = 10 +: list1
    val list3 = list1 :+ 23
    println(list1)
    println(list2)
    println(list3)
    println("======================================================")
    val value = list2.::(51)
    println(value)
    val list5 = Nil.::(13)
    println(list5)
    val list6 = 32 :: Nil
    println(list6)
    val list7 = 12 :: 45 :: 89 :: 32 :: Nil
    println(list7)
    println("======================================================")
    val list8 = list6 :: list7
    println(list8)
    val list9 = list6 ::: list7
    println(list9)
    val list10 = list6 ++ list7
    println(list10)
  }
}
